package com.mercury.ec.module.air.enums;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjUtil;
import com.mercury.ec.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 机票需求方案状态枚举
 *
 * @author hesx
 */
@Getter
@AllArgsConstructor
public enum AirDemandSchemeStatusEnum implements IntArrayValuable {

    CANCELED(0, "已取消"),
    WAIT_PRICING(1, "待核价"),
    PRICED(2, "已核价"),
    ;


    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AirDemandSchemeStatusEnum::getStatus).toArray();

    public static final String DICT_TYPE = "air_demand_scheme_status";

    /**
     * 值
     */
    private final Integer status;
    /**
     * 名称
     */
    private final String name;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static AirDemandSchemeStatusEnum getByStatus(int status) {
        return ArrayUtil.firstMatch(o -> o.getStatus().equals(status), values());
    }

    public static boolean isCanceled(Integer status) {
        return ObjUtil.equal(CANCELED.status, status);
    }

    public static boolean isWaitPricing(Integer status) {
        return ObjUtil.equal(WAIT_PRICING.status, status);
    }

    public static boolean isPriced(Integer status) {
        return ObjUtil.equal(PRICED.status, status);
    }
}
